﻿using System;

namespace eCommerce.SagePay.TestSite
{
    public partial class _DComplete : System.Web.UI.Page
    {
        private string MD;
        private string VendorTxCode;
        private string PaRes;
        private string postString;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form["MD"] != null)
            {
                MD = Request.Form["MD"];
                PaRes = Request.Form["PaRes"];
                VendorTxCode = Session["VendorTxCode"].ToString();

                //'** POST for Sage Pay  Direct 3D completion page **
                postString = "MD=" + MD + "&PARes=" + Server.UrlEncode(PaRes);

                try
                {
                    HttpRequestHelper helper = new HttpRequestHelper();
                    string response = helper.PostRequest(VendorTxCode, postString, "3dcallback");

                    // Update the DB

                }
                catch (Exception exception)
                {
                    // update the DB with negative response
                }
            }
        }
    }
}
